//
//  ViewDBPageDetail.m
//  MyBarcodeStore
//
//  Created by mac on 2010/7/26.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "ViewDBPageDetail.h"


@implementation ViewDBPageDetail

@synthesize rowTitle;
@synthesize result;

- (id)initWithStyle:(UITableViewStyle)style {
	if ((self = [super initWithStyle:style]) != nil)
	{
		self.title = @"詳細資料";
		
		rowTitle = [[NSArray alloc] initWithObjects:@"品名", @"價錢", @"產地", nil];
	}
	
	return self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [rowTitle count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	/*
	static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
    }
	*/
	
	UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:nil] autorelease];
	
	cell.textLabel.text = (NSString *)[rowTitle objectAtIndex:indexPath.row];
	
	if (result != nil) {
		switch (indexPath.row) {
			case 0:
				cell.detailTextLabel.text = result.name;
				break;
			case 1:
				cell.detailTextLabel.text = [result.price stringValue];
				break;
			case 2:
				cell.detailTextLabel.text = result.origin;
				break;
			default:
				break;
		}
	}
	
	return cell;
}

- (void)dealloc {
	[rowTitle release];
	[result release];
	[super dealloc];
}

@end
